package org.jprobe;

import java.util.Arrays;
import java.util.List;

/**
*
* Settings handler
*
* @author Hussain Al-Mutawa
* @version 1.0
* @since 1.0
*/
public class Settings implements SettingsInterface {
	/** //TODO add documentation **/
	private transient String lastDir,preferredDir;
	/** //TODO add documentation **/
	private transient List<String>history;
	/** //TODO add documentation **/
	private transient String settingsFile;

	@Override
	public String getLastDirectory() {
		return lastDir;
	}

	@Override
	public void setLastDirectory(final String lastDir) {
		this.lastDir = lastDir;
	}

	@Override
	public String getPreferredDirectory() {
		return preferredDir;
	}

	@Override
	public void setPreferredDirectory(final String preferredDir) {
		this.preferredDir = preferredDir;
	}

	@Override
	public String[] getHistory() {
		return history.toArray(new String[this.history.size()]);
	}

	@Override
	public void setHistory(final List<String> history) {
		this.history = history;
	}

	@Override
	public void writeSettingsToFile(final String fileName) throws JProbeException{
		this.settingsFile=fileName;
		throw new JProbeRuntimeException("Not Implemented yet");
	}

	@Override
	public void readSettingsFromFile(final String fileName) throws JProbeException{
		this.settingsFile=fileName;

		//dummy implementation
		this.setLastDirectory("./..");
		this.setPreferredDirectory("./..");
		this.setHistory(Arrays.asList(
				new String[]{
				"./../colt-1.2.0",
				"./../jdepend",
				"./../jext-5.0",
				"./../jfreechart-1.0.14",
				"./../json2xml",
				"./../log4j-1.2.16",
				"./../umlducate"
		}));
		//throw new UnsupportedOperationException("Not Implemented yet");
	}

	@Override
	public String getSettingsFileName() {
		return settingsFile;
	}

	@Override
	public void addProjectToHistory(final String project) {
		throw new JProbeRuntimeException("Not Implemented yet");
	}
}
